<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>患者清单</title>

    <link rel="stylesheet" th:href="@{lixueypng/bootstrap-3.3.5-dist/css/bootstrap.min.css}">

    <script th:src="@{lixueypng/js/jquery-2.1.0.min.js}"></script>
    <script th:src="@{lixueypng/bootstrap-3.3.5-dist/js/bootstrap.min.js}"></script>

   <!-- <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

    &lt;!&ndash; jQuery文件。务必在bootstrap.min.js 之前引入 &ndash;&gt;
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>

    &lt;!&ndash; 最新的 Bootstrap 核心 JavaScript 文件 &ndash;&gt;
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
-->
   <script th:src="@{lixueypng/layer/layer.js}"></script>

</head>
<body>

    <div class="container" >
        <table class="table table-striped">

            <thead>

            <tr>
                <th>编号</th>
                <th>姓名</th>
                <th>预约时间</th>
            </tr>

            </thead>

            <tbody>

            <tr id="12" th:each="item:${patientis}">

                    <td id="id" th:text="${item.getId()}"></td>
                    <td id="name" th:text="${item.getName()}"></td>
                    <td id="orderdata" th:text="${item.getOrderdata()}"></td>

                     <form action="/checkl" method="post" >
                         <td>
                             <input type="text" name="id" class="hidden"/>
                             <button type="submit" class="btn btn-primary"  onclick="find(this)"> 查询</button>
                         </td>
                     </form>

                    <!-- <form action="/delete" method="post" >-->
                         <td>
                            <!-- <input type="text" name="id" class="hidden"/>-->
                             <button type="button" class="btn btn-danger" onclick="dele(this)"> 删除</button>
                         </td>
                    <!-- </form>-->
            </tr>

            </tbody>
        </table>

    </div>
</body>


<script>


    //实现将当前行id值放入form的<input/>标签中
    function find(obj) {

       var id=$(obj).parent().siblings('#id').text();

        $(obj).prev().val(id);

      // alert( $(obj).prev().attr("value"));
       //$(obj).val(id);
        //alert($(obj).attr("value"))
    }

    function dele(obj){
        //询问框
        var id=$(obj).parent().siblings('#id').text();
        layer.confirm('确认删除？', {
                btn: ['取消','确定'] //按钮
            },
            function(){
                layer.msg('取消');
            },
            function(){

                $.ajax({
                    type: "POST",
                    url: "/deletel",
                    data: {"id":id},
                    dataType: "html",
                    success:function () {
                        window.location.reload();
                    }
                })

            });

    }

</script>
</html>